package chapter2.section2;

/**
 * 程序 2-2：一个关于不同类型变量的程序
 *
 * @author 张玮婷 20245080902061
 */

public class Circle {
    static final double PI = 3.14;
    int radius;

    public Circle(int r) {
        super();
        this.radius = r;
    }

    public static void main(String[] args) {
        Circle c = new Circle(5);
        //下面的area是一个局部变量，与computeArea方法中的变量area无关
        double area = c.computeArea();
        System.out.println("半径是5的圆的面积是" + area);
        c.changeRadius(6);
        area = c.computeArea();
        System.out.println("半径是6的圆面积是" + area);
    }

    public double computeArea() {
        double area = 0.0;
        area = PI * radius * radius;
        return area;
    }

    public void changeRadius(int r) {
        this.radius = r;
    }
}
